import time
def bubble_sort(m1):
   swapped = True
   a = time.time()
   while swapped:
      swapped = False
      for i in range(len(m1) - 1):
         if m1[i] > m1[i+1]:
            m1[i], m1[i+1] = m1[i+1], m1[i]
            swapped = True
   b = time.time()
   return round(((b - a) * 1000), 2)

def read2list(m1):
  with open(m1, 'r') as file:
      data = file.readlines()
  return data

m1 = read2list("m1_sorted.txt")
m2 = read2list("m2_reverse.txt")
m3 = read2list("m3_shuffle.txt")

print('m1_sorted ', bubble_sort(m1), 'milliseconds')
print('m2_reverse ', bubble_sort(m2), 'milliseconds')
print('m3_shuffle ', bubble_sort(m3), 'milliseconds')












